package huoye.shops.huoye.operation.activity;

import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.base.BaseActivity;
import huoye.shops.huoye.user.model.Province;

public class EditSelectDiscountActivity extends BaseActivity{


    //定义一个String类型的List数组作为数据源
    private List<String> dataList;

    //定义一个ArrayAdapter适配器作为spinner的数据适配器
    private ArrayAdapter<String> adapter;


    @BindView(R.id.sp_select_discount)
    Spinner spDiscount;



    @Override
    protected int getContentViewId() {
        return R.layout.activity_edit_select_discount;
    }

    @Override
    protected void initView(@Nullable Bundle bundle) {
        setTitle("编辑");
        setSpData();


    }


    private void setSpData(){
        dataList = new ArrayList<>();
        dataList.add("一折");
        dataList.add("二折");
        dataList.add("三折");
        dataList.add("四折");
        dataList.add("五折");

        adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, dataList);

        spDiscount.setAdapter(adapter);
        spDiscount.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parent, View view,
                                       int pos, long id) {

                makeToast("你点击的是:"+adapter.getItem(pos));

            }
            @Override
            public void onNothingSelected(AdapterView<?> parent) {
                makeToast("请选择你的折扣");

            }
        });
    }
}
